import Vue from "vue";
import VueRouter from "vue-router";
import Home from "../views/Home.vue";

Vue.use(VueRouter);

const routes = [{
  path: "/",
  name: "Home",
  component: Home,
  redirect: "/Index",
  children: [{
    path: "/Index",
    name: "Index",
    meta: {
      hidden: true,
      title: "首页-蕴啸"
    },
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
      import( /* webpackChunkName: "about" */ "../views/index.vue")
  },
  {
    path: "/Spread",
    name: "Spread",
    meta: {
      hidden: true,
      title: "产品服务-公关传播-藴啸"
    },
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
      import(
        /* webpackChunkName: "about" */
        "../views/productsAndservices/spread.vue"
      )
  },

  {
    path: "/Marketing",
    name: "Marketing",
    meta: {
      hidden: true,
      title: "产品服务-数字化营销-藴啸"
    },
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
      import(
        /* webpackChunkName: "about" */
        "../views/productsAndservices/marketing.vue"
      )
  },
  {
    path: "/Design",
    name: "Design",
    meta: {
      hidden: true,
      title: "产品服务-创意设计-藴啸"
    },
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
      import(
        /* webpackChunkName: "about" */
        "../views/productsAndservices/design.vue"
      )
  },
  {
    path: "/Offline",
    name: "Offline",
    meta: {
      hidden: true,
      title: "产品服务-营销工具-藴啸"
    },
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
      import(
        /* webpackChunkName: "about" */
        "../views/productsAndservices/offline.vue"
      )
  },
  {
    path: "/Monitor",
    name: "Monitor",
    meta: {
      hidden: true,
      title: "产品服务-线下公关-藴啸"
    },
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
      import(
        /* webpackChunkName: "about" */
        "../views/productsAndservices/monitor.vue"
      )
  },

  {
    path: "/Case",
    name: "Case",
    meta: {
      hidden: true,
      title: "客户案例-藴啸"
    },
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
      import(
        /* webpackChunkName: "about" */
        "../views/case.vue"
      )
  },
  {
    path: "/CaseDetail",
    name: "CaseDetail",
    meta: {
      hidden: true,
      title: "客户案例详情-藴啸"
    },
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
      import(
        /* webpackChunkName: "about" */
        "../views/caseDetail.vue"
      )
  },
  {
    path: "/About",
    name: "About",
    meta: {
      hidden: true,
      title: "关于我们-藴啸"
    },
    component: () =>
      import(
        /* webpackChunkName: "about" */
        "../views/About.vue"
      )
  },
  {
    path: "/Contact",
    name: "Contact",
    meta: {
      hidden: true,
      title: "联系我们-藴啸"
    },
    component: () =>
      import(
        /* webpackChunkName: "about" */
        "../views/contact.vue"
      )
  },
  {
    path: "/NewsList",
    name: "NewsList",
    meta: {
      hidden: true,
      title: "新闻中心-藴啸"
    },
    component: () =>
      import(
        /* webpackChunkName: "about" */
        "../views/news/list.vue"
      )
  },
  {
    path: "/NewsDetail",
    name: "NewsDetail",
    meta: {
      hidden: true,
      title: "新闻中心详情-藴啸"
    },
    component: () =>
      import(
        /* webpackChunkName: "about" */
        "../views/news/detail.vue"
      )
  },
  ]
}];
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  scrollBehavior: () => ({
    y: 0
  }),
  routes
});
router.beforeEach((to, from, next) => {
  if (to.meta.title) {
    document.title = to.meta.title
  }
  // let body = document.getElementsByTagName("body")[0];
  // body.classList.remove("locking");
  next()
})

export default router;